package com.receive.game.message;
import java.util.Date;

import com.base.conn.BaseClientSession;
import com.base.conn.BaseServiceSession;
import com.base.wslisten.ChannelSupervise;
import com.base.wslisten.WSServerListen;
import com.google.gson.Gson;
import com.msg.ClientMsg;

import io.netty.channel.Channel;

public class ReceivedGameMessage {
	public static void Read(BaseServiceSession baseServiceSession) {
		String msgString = baseServiceSession.getMsgString().toString();
		Gson gson = new Gson();
		ClientMsg resCathInfo = gson.fromJson(msgString, ClientMsg.class);
		String playersId = WSServerListen.getAllIdRelationSessionIdConcurrentHashMap().get(resCathInfo.getSessionId());
		Channel channel = ChannelSupervise.findChannel(playersId);
		if (channel != null) {
			System.out.println("ok ,all finish");
			System.out.println(msgString);
			channel.writeAndFlush(msgString);
			BaseClientSession tws = new BaseClientSession(channel.id(),
					new Date().toString() + channel.id() + "：" + msgString);
			channel.writeAndFlush(tws);
		}
	}
}
